#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#define ll long long
using namespace std;
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	int n;
	bool use[10000000],a[10000000],u[1000000],v[10000000],t=0;
	memset(use,0,sizeof use);
	memset(u,0,sizeof u);
	memset(v,0,sizeof v);
	memset(a,0,sizeof a);
	for(int i=0;i<n;i++){
		cin>>n;
		cin>>a[i];
	}
	for(int i=1;i<n;i++){
		if(a[i]!=a[i-1]){
			v[t]=i-1;
			u[++t]=i;
		}
	}
	while(1){
		for(int i=0;i<t;i++){
			if(!use[i]){
				cout<<u[i];
				u[i]++;
				if(u[i]>=v[i]){
					use[i]=1;
				}
			}
		}
		bool flag=0;
		for(int i=0;i<t;i++){
			if(use[i]&&i==t-1){
				flag=1;
			}
		}
		if(flag)break;
	}
	return 0;
}
